package com.sk.cardeal.act.home.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.sk.cardeal.R;
import com.sk.cardeal.adapter.ChooseAdapter;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.common.Constants;
import com.sk.cardeal.view.TitleView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sk on 2018/1/17.
 */

public class ChooseActivity extends BaseActivity implements AdapterView.OnItemClickListener {
    @BindView(R.id.title_view)
    TitleView titleView;
    @BindView(R.id.pic_ryc)
    ListView picRyc;

    private String title;
    private int type;

    private String[] arrays;
    private ChooseAdapter adapter;

    @Override
    protected int getContentView() {
        return R.layout.activity_choose;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        title = getIntent().getStringExtra("title");
        type = getIntent().getIntExtra("type", 0);

        switch (type) {
            case Constants.IS_CLEAN:
                arrays = getResources().getStringArray(R.array.clean_car);
                break;
            case Constants.IS_HANDLE:
                arrays = getResources().getStringArray(R.array.parts_handle);
                break;
        }
        adapter = new ChooseAdapter(mContext, arrays);
        picRyc.setAdapter(adapter);
        picRyc.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent();
        intent.putExtra("data", arrays[position]);
        setResult(RESULT_OK, intent);
        finish();
    }
}
